package cn.auto.controller;

import java.util.HashMap;
import java.util.List;

import com.jfinal.core.ActionKey;

import cn.auto.service.CaseService;
import cn.auto.utility.HelperController;
import cn.auto.utility.Status;

public class CasesController extends HelperController {
	
	CaseService service=new CaseService();
	
	public void index() {
		String pid=getPara("pid");
		HashMap<Object, Object> result=service.getCases(pid);
		String st = (String) result.get("status"); 
		HashMap<String, String> msg=new HashMap<>();
		msg.put(Status.SUCCESS, "获取成功!");
		msg.put(Status.NORECORD, "无记录!");
		msg.put(Status.FAILED, "获取失败!");
		responseResult(st,msg,(List<?>) result.get("body"));
	}
	
	@ActionKey("/case/search")
	public void getCase() {
		String pid=getPara("pid");
		String m = getPara("module");
		String s_name = getPara("cases");
		HashMap<Object, Object> result=service.getCases(pid,m,s_name);
		String st = (String) result.get("status"); 
		HashMap<String, String> msg=new HashMap<>();
		msg.put(Status.SUCCESS, "获取成功!");
		msg.put(Status.NORECORD, "无记录!");
		msg.put(Status.FAILED, "获取失败!");
		responseResult(st,msg,(List<?>) result.get("body"));
	}
	
	@ActionKey("/case/module")
	public void getModuleCase() {
		String pid=getPara("pid");
		String m = getPara("module");
		HashMap<Object, Object> result=service.getCases(pid,m);
		String st = (String) result.get("status"); 
		HashMap<String, String> msg=new HashMap<>();
		msg.put(Status.SUCCESS, "获取成功!");
		msg.put(Status.NORECORD, "无记录!");
		msg.put(Status.FAILED, "获取失败!");
		responseResult(st,msg,(List<?>) result.get("body"));
	}
	
	@ActionKey("/case/suite")
	public void getSuitCase() {
		String sid= getPara("sid");
		HashMap<Object, Object> result=service.getSuiteCase(sid);
		String st = (String) result.get("status"); 
		HashMap<String, String> msg=new HashMap<>();
		msg.put(Status.SUCCESS, "获取成功!");
		msg.put(Status.NORECORD, "无记录!");
		msg.put(Status.FAILED, "获取失败!");
		responseResult(st,msg,(List<?>) result.get("body"));
	}
	
}
